package org.jeecg.modules.lab.items.temp.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.lab.items.temp.entity.LabItemsTempNorm;
import org.jeecg.modules.lab.items.temp.mapper.LabItemsTempNormMapper;
import org.jeecg.modules.lab.items.temp.service.ILabItemsTempNormService;
import org.jeecg.modules.lab.items.vo.LabTempNorm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description: 实验项目模板_检测条件信息
 * @Author: jeecg-boot
 * @Date:   2023-10-08
 * @Version: V1.0
 */
@Service
public class LabItemsTempNormServiceImpl extends ServiceImpl<LabItemsTempNormMapper, LabItemsTempNorm> implements ILabItemsTempNormService {


    @Autowired
    private LabItemsTempNormMapper labItemsTempNormMapper;

    @Override
    public List<LabTempNorm> handTempData(String itemId) {
        List<LabTempNorm> tempNormList = labItemsTempNormMapper.getTempNormList(itemId);
        QueryWrapper<LabItemsTempNorm> queryWrapper = new QueryWrapper<>();
        for (LabTempNorm labTempNorm : tempNormList) {
            queryWrapper.clear();
            queryWrapper.eq("field_row", labTempNorm.getNId())
                    .eq("item_id", itemId)
                    .orderByAsc("field_sort");
            List<LabItemsTempNorm> itemsTempNormList = labItemsTempNormMapper.selectList(queryWrapper);
            labTempNorm.setLabItemsTempNormList(itemsTempNormList);
        }
        return tempNormList;
    }
}
